package org.springblade.common.utils.message.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;

import java.util.HashMap;
import java.util.Map;


/**
 * @Author ysq
 * @Date 2024/09/19
 * @Description 消息相关参数
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MessageParam {

    @ApiModelProperty(value = "客户端回调参数")
    private Map<String, Object> callback;

    @ApiModelProperty(value = "接收者，多个逗号分隔")
    private String receiver;

    @ApiModelProperty(value = "消息内容中的可变部分(占位符替换)")
    private Map<String, String> variables;

    @ApiModelProperty(value = "扩展参数")
    private Map<String, String> extra;

	public Map<String, Object> getCallback() {
		if (callback == null) {
			callback = new HashMap<>(2);
		}
		if (!callback.containsKey(BladeConstant.MDC_TENANT_ID_KEY)) {
			callback.put(BladeConstant.MDC_TENANT_ID_KEY, AuthUtil.getTenantId());
		}
		return callback;
	}

}
